
<!--#include file="functions.asp" -->

<%
'on error resume next
'set cn=Server.CreateObject("ADODB.Connection")
'cn.Open "MP2ENTTEST2", "MP2", "MP2"
dim sql

sql ="UPDATE EXIREG SET INVSTATUS='PAID',"
sql = sql & " PAYMENTDATE='" & request("Payment_Date") & "'"
'sql = sql & " AMOUNTPAID=" & delKoma(request("total_amt"))
sql = sql & " WHERE SEQNUM IN (" & request("chkItem") & ")"
'response.write sql
'cn.execute(sql)

arrItem = Split(Request("chkItem"),",")

'For test only
'response.write uBound(Split(Request("chkItem"),","))

for i=0 to uBound(arrItem)
  'For test only
	'response.write arrItem(i)
	
	sql ="UPDATE EXIREG SET INVSTATUS='PAID',"
	sql = sql & " PAYMENTDATE='" & request("Payment_Date") & "'"
	'sql = sql & " AMOUNTPAID=" & delKoma(request("total_amt"))
	sql = sql & " WHERE SEQNUM = '" & arrItem(i) & "'"
	cn.execute(sql)
	
	sql  = "INSERT INTO EXIHIST (SEQNUM, TRANSTYPE, LOCATION, DEPARTMENT, DATE, UPDATEUSER, UPDATESTAMP)"
	sql = sql & " VALUES('" & arrItem(i) & "','IPD','FINANCE','FINANCE',getDate(),'" & UsrName & "',getDate())"
	cn.execute(sql)
	
next
 
response.redirect "inv_payment.asp?InvStatus=0&RefOrder=0&CurSymbol=N"
%>
